﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LWrap.Interfaces;
using Lucene.Net.Analysis;
using Lucene.Net.Analysis.Standard;
namespace LWrap.CustomLWrapps
{
    public class SynonymPhraseStopWordAnalyzer:Analyzer
    {
        private ISynonymsCache _synonymCache = null;
        private IPhraseaCache _phraseCache = null;

        public SynonymPhraseStopWordAnalyzer(ISynonymsCache synCache, IPhraseaCache phraseCache)
        {
            _synonymCache = synCache;
            _phraseCache = phraseCache;
        }

        public override TokenStream TokenStream(string fieldName, System.IO.TextReader reader)
        {
            Tokenizer tokenizer = new StandardTokenizer(reader);
            TokenFilter lowerCaseFilter = new LowerCaseFilter(tokenizer);
            TokenFilter stopFilter = new StopFilter(lowerCaseFilter,PorterStemStopAnalyzer.stopWords);
            return new SynonymPhraseStopWordFilter(stopFilter,this._synonymCache, this._phraseCache);
        }
    }
}
